<?php

class AutoLoad extends \Home {

    public static function includeClass($className) {
        $arr = explode('\\', $className);
        if ($arr[0] == 'Lib') {
            $dir = __DIR__ . '/';
        } elseif (in_array($arr[0], array('Controller'))){
            $dir = APP_DIR . '/';
        } elseif ($arr[0] == 'Config') {
			$dir = CONFIG_DIR . '/';
			unset($arr[0]);
		} else if (count($arr) == 1) {
            $dir = COMMON_DIR . '/Import/';
        }
        else {
            $dir = COMMON_DIR . '/';
        }
        $fileName = array_pop($arr) . '.php';
        $file = $dir;
        foreach ($arr as $v) {
            $file .= $v . '/';
        }
		$file .= $fileName;
		if (in_array($className, array('phpQuery', 'Redis'))) {
			$file = __DIR__ . '/Lib/Import/' . $className . '.php';
		}
		if (!is_readable($file)) {
			//throw new \Lib\Exception\System('文件加载失败:' . $file);
		} else {
            require_once $file;
        }
    }
}
